﻿using WH.Model.Bases;
using WH.Common.Bases.IBase;
using SqlSugar;

namespace WH.Model.Systems
{
    ///<summary>
    ///系统用户表
    ///</summary>
    [SugarTable("sys_user")]
    public class UserEntity : BaseOrgAuditableEntity, IOrganizationFilter
    {
        /// <summary>
        /// 账户 这里作为登录账号 一般以拼音为主
        /// </summary>
        [SugarColumn(ColumnName = "user_account", IsNullable = false, Length = 50, ColumnDescription = " 账户 这里作为登录账号")]
        public string Account { get; set; } = null!;

        /// <summary>
        /// 真实姓名
        /// </summary>
        [SugarColumn(ColumnName = "real_name", IsNullable = true, Length = 50, ColumnDescription = "真实姓名")]
        public string Name { get; set; } = null!;

        /// <summary>
        /// 头像路径
        /// </summary>
        [SugarColumn(ColumnName = "avatar", IsNullable = true, Length = 255, ColumnDescription = "头像路径")]
        public string? AvatarUrl { get; set; }

        /// <summary>
        /// 用户性别（1男 0女 2未知）
        /// </summary>
        [SugarColumn(ColumnName = "sex", IsNullable = true, Length = 50, ColumnDescription = "用户性别（1男 0女 2未知）")]
        public string? Sex { get; set; }

        /// <summary>
        /// 手机号码 11位
        /// </summary>
        [SugarColumn(ColumnName = "mobile_phone", IsNullable = true, Length = 50, ColumnDescription = "手机号码 11位")]
        public string PhoneNumber { get; set; } = null!;

        /// <summary>
        /// 邮箱
        /// </summary>
        [SugarColumn(ColumnName = "email", IsNullable = true, Length = 50, ColumnDescription = "邮箱")]
        public string? Email { get; set; }

        /// <summary>
        /// 组织主键部门 读取sys_organize表中的fid
        /// </summary>
        [SugarColumn(ColumnName = "depment_id", IsNullable = true, Length = 50, ColumnDescription = "组织主键部门")]
        public string? DepartmentId { get; set; }

        /// <summary>
        /// 编号
        /// </summary>
        [SugarColumn(ColumnName = "code", IsNullable = true, Length = 50, ColumnDescription = "编号")]
        public string? Code { get; set; }

        /// <summary>
        /// 部门
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(DepartmentId))]
        public OrganizationEntity? Department { get; set; }

        /// <summary>
        /// 角色主键  读取sys_role表中category=1的fid
        /// </summary>
        [SugarColumn(ColumnName = "sys_role_fid", IsNullable = true, Length = 50, ColumnDescription = "角色主键")]
        public string? RoleId { get; set; }

        /// <summary>
        /// 角色
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(RoleId))]
        public RoleEntity? Role { get; set; }

        ///// <summary>
        ///// 岗位主键  读取sys_role表中category=2的fid
        ///// </summary>
        //[SugarColumn(ColumnName = "sys_duty_fid", IsNullable = true, Length = 50, ColumnDescription = "岗位主键")]
        //public string? DutyId { get; set; }

        ///// <summary>
        ///// 岗位
        ///// </summary>
        //[Navigate(NavigateType.OneToOne, nameof(DutyId))]
        //public DutyEntity? Duty { get; set; }

        /// <summary>
        /// 是否管理员  (0否 1是)
        /// </summary>
        [SugarColumn(ColumnName = "is_administrator", IsNullable = true, Length = 1, ColumnDescription = "是否管理员")]
        public bool IsAdministrator { get; set; }

        /// <summary>
        /// 排序码 数字越小越靠前
        /// </summary>
        [SugarColumn(ColumnName = "sort_code", IsNullable = true, Length = 11, ColumnDescription = "排序码")]
        public int SortCode { get; set; }

        /// <summary>
        /// 状态（0停用 1正常）
        /// </summary>
        [SugarColumn(ColumnName = "is_enable", IsNullable = true, Length = 1, ColumnDescription = "状态（0停用 1正常）")]
        public bool IsEnable { get; set; } = true;

        /// <summary>
        /// 描述/备注说明
        /// </summary>
        [SugarColumn(ColumnName = "remark", IsNullable = true, Length = 255, ColumnDescription = "描述/备注说明")]
        public string? Remark { get; set; }

        /// <summary>
        /// 登录次数
        /// </summary>
        [SugarColumn(ColumnName = "logon_count", IsNullable = true, Length = 11, ColumnDescription = "登录次数")]
        public int LogonCount { get; set; }

        /// <summary>
        /// 证件类型
        /// </summary>
        [SugarColumn(ColumnName = "card_type_code", IsNullable = true, Length = 50, ColumnDescription = "证件类型")]
        public string? CardTypeCode { get; set; }

        /// <summary>
        /// 证件号
        /// </summary>
        [SugarColumn(ColumnName = "card_type_no", IsNullable = true, Length = 50, ColumnDescription = "证件号")]
        public string? CardTypeNo { get; set; }

        /// <summary>
        /// 类型
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(CardTypeCode), nameof(KeyValueEntity.Code))]
        public KeyValueEntity? CardType { get; set; }

        /// <summary>
        /// 微信号
        /// </summary>
        [SugarColumn(ColumnName = "wei_xin", IsNullable = true, Length = 50, ColumnDescription = "微信号")]
        public string? WeiXin { get; set; }

        /// <summary>
        /// 访问类型 1：系统用户   2：对接用户
        /// </summary>
        [SugarColumn(ColumnName = "access_type", IsNullable = true, Length = 11, ColumnDescription = "访问类型 1：系统用户   2：对接用户")]
        public int? AccessType { get; set; }

        /// <summary>
        /// 用户类型
        /// </summary>
        [SugarColumn(ColumnName = "user_type_code", IsNullable = true, Length = 50, ColumnDescription = "用户类型")]
        public string? UserTypeCode { get; set; }

        /// <summary>
        /// 类型
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(UserTypeCode), nameof(KeyValueEntity.Code))]
        public KeyValueEntity? UserType { get; set; }

        /// <summary>
        /// 生日
        /// </summary>
        [SugarColumn(ColumnName = "birthday", IsNullable = true, ColumnDescription = "生日")]
        public DateTime? Birthday { get; set; }

        /// <summary>
        /// 机构id
        /// </summary>           
        [SugarColumn(ColumnName = "organization_id", IsNullable = false, Length = 50, ColumnDescription = "机构id")]
        public override string OrganizationId { get; set; } = null!;
    }
}